function y=mat2streval(x,y)

%MAT2M converts matlab variable in a string that can be evaluated back
%Syntax: y=mat2streval(x,v)
%Description: x is a matlab variable and v is an optional string being 
%             carried over from a previous operation. Most users will not
%             need to use it but it is very useful for recursive uses of
%             this function.
%
%Jonas Almeida, 23 February 2006

if nargin <2;y='';end
c=class(x);
switch c
    case 'double'
        y=[y,'temp=zeros(',strrep(num2str(size(x)),'  ',','),');temp(:)=[',regexprep(num2str(x(:)'),'\s+',','),']'];
end
        
